﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
using System.Web.UI;
using System.Web.UI.WebControls;
using Data;

namespace WebSolutions
{
    public partial class Contacto : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Enviar consulta al correo definido
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        protected void butSent_Click(object sender, EventArgs e)
        {
            consultaRegistrar();
            Response.Redirect("~/Gracias.aspx");
        }

        /// <summary>
        /// registrar consulta
        /// </summary>
        private void consultaRegistrar()
        {
            using (var db = new context())
            {
                Consulta cons = new Consulta();
                cons.EmailContacto = this.txtEmail.Text;
                cons.Mensaje = this.txtDescripcion.Text;
                cons.Tipo = this.txtAsunto.Text;
                cons.NombreContacto = txtNombre.Text;

                db.Consultas.Add(cons);
                db.SaveChanges();
            }
        }


    }
}
